package org.framework.core.validate.support.param;

import javax.servlet.http.HttpServletRequest;

import org.framework.core.error.support.Errors;
import org.framework.core.util.StringUtil;
import org.framework.core.validate.exception.ParamFormatException;
import org.framework.core.validate.exception.ValidationException;
import org.framework.define.bean.result.Errcode;

/**
 *	时间参数
 *	继承该类,将按照 {@link #format} 格式化验证参数
 */
public class TimeParam extends ValidateParam {
	
	protected String format;
	
	@Override
	protected Errcode validateValue(HttpServletRequest request, String paramString) throws ValidationException {
		if(StringUtil.isDate(paramString, format))
			throw new ParamFormatException(this);
		return Errors.OK;
	}

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}
}
